<template>
  <div class="mvItem">
    <!-- 骨架屏 -->
    <div class="content" v-if="list.length === 0">
      <div class="content_item" v-for="item in 10" :key="item">
        <el-skeleton animated :throttle="500" style="width: 100%">
          <template slot="template">
            <el-skeleton-item
              variant="image"
              style="height: 127px; width: 100%; border-radius: 8px"
            />
            <el-skeleton-item
              variant="p"
              style="height: 30px; width: 100%; margin-top: 8px"
            />
            <el-skeleton-item
              variant="p"
              style="height: 20px; width: 100%; margin-top: 8px"
            />
            <el-skeleton-item
              variant="p"
              style="height: 10px; width: 100%; margin-top: 8px"
            />
          </template>
        </el-skeleton>
      </div>
    </div>

    <div class="content" v-else>
      <div
        class="content_item"
        v-for="item in list"
        :key="item.id"
        @click="mvItemClick(item.id)"
      >
        <div class="content_item_pic">
          <GlobalImageDeep :url="item.cover" :imgWidth="224" :imgHeight="127" />
          <!-- 播放按钮 -->
          <GlobalPlayMask
            :maskWidth="64"
            :maskHeight="64"
            @maskClick="toMvDetailsPage(item.id)"
          />
        </div>
        <div class="name one_txt_cut">{{ item.name }}</div>
        <div class="author one_txt_cut">{{ formatAuthor(item.artists) }}</div>
        <div class="count">
          <i class="el-icon-video-camera"></i>
          {{ getCount(item.playCount) }}
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getCount } from "../utils/format";
export default {
  name: "mvItem",
  components: {},
  props: {
    list: {
      required: true,
      type: Array,
      default: () => [],
    },
  },
  data() {
    return {};
  },
  created() {},
  methods: {
    getCount,
    formatAuthor(artists) {
      let authors = "";
      artists.forEach((item) => {
        authors = authors + item.name + " / ";
        // console.log(authors);
      });
      return authors.slice(0, authors.length - 2);
    },
    mvItemClick(id) {
      this.$emit("mvItemClick", id);
    },
    toMvDetailsPage(id) {
      console.log("mv点击");
      this.$router.push(`/mvDetails/${id}`);
    },
  },
  computed: {},
};
</script>

<style lang="less" scoped>
.mvItem {
  /deep/ .el-image {
    img {
      border-radius: 8px;
    }
  }
  .content {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    .content_item {
      font-size: 14px;
      color: #333333;
      width: 224px;
      padding-bottom: 15px;
      .name {
        margin: 5px 0;
        font-size: 16px;
        &:hover {
          color: @globalColor;
          cursor: pointer;
          // animation: bounce 1s;
        }
      }
      .author {
        color: #999999;
        margin-bottom: 8px;
        &:hover {
          color: @globalColor;
          cursor: pointer;
          // animation: bounceIn 1s;
        }
      }
      .count {
        color: #999999;
      }
      .content_item_pic {
        position: relative;
        width: 224px;
        height: 127px;
        &:hover {
          /deep/ .playMask .play {
            display: block;
            cursor: pointer;
          }
        }
      }
    }
  }
}
</style>
